package cn.tedu.search.entity;

import lombok.experimental.Accessors;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;


@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
//@Document是SpringDataElasticsearch框标记一个对应ES实体类的注解
//indexName属性指定当前实体类对应索引的名称,运行时如果索引不存在，会自动创建这个索引
@Document(indexName = "items")
public class Item implements Serializable {

    @Id
    private Long id;

    @Field(type = FieldType.Text,
            analyzer = "ik_max_word",
            searchAnalyzer = "ik_max_word")
    private String title;

    @Field(type = FieldType.Keyword)
    private String category;

    @Field(type = FieldType.Keyword)
    private String brand;

    @Field(type = FieldType.Double)
    private Double price;

    @Field(type = FieldType.Keyword,index = false)
    private String imgPath;
}
